package com.company;

import java.util.*;

public class SetClass {

    Set<String> set = new TreeSet<>(new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return -o1.compareTo(o2);
        }
    });
    public SetClass() {
        set.add("link");
        set.add("ldq");
        set.add("ldq");
        set.add("ltx");
        sord();
    }
    void forEach(){
        for(Object s : this.set){
            System.out.println(s);
        }
    }
    void sord(){
        List<String> list1 = Arrays.asList("ldq","link","ltx","ldq","link");
        List<String> list2 = removeDuplicate(list1);
        for(String s :list1){
            System.out.print("-"+s);
        }
        System.out.println("");
        for(String s :list2){
            System.out.print("-"+s);
        }
    }

    private List<String> removeDuplicate(List<String> list1) {
        Set<String> set = new HashSet<String>();
        set.addAll(list1);
        return new ArrayList<String>(list1);
    }
}
